<template>
  <div class="libs-charts">
    <div class="header">
      <p class="subject">库区使用情况</p>
    </div>

    <!-- 图表 -->
    <chart :chartData="chartData" />
  </div>
</template>

<script lang="ts">
import { getAreaUseInformation } from '@/module-base/api/dashboard'
import { Component, Vue } from 'vue-property-decorator'
import { IPieChartData } from '../use-charts/charts/index.vue'
import Chart from './charts/index.vue'

@Component({
  name: 'LibCharts',
  components: {
    Chart
  }
})
export default class extends Vue {
    private chartData = {} as IPieChartData

    created() {
      this.initData()
    }

    private async initData() {
      const { data } = await getAreaUseInformation()
      const series = data
      const legend = [] as string[]
      for (const item of series) {
        legend.push(item.name)
      }
      this.chartData = {
        series, legend
      }
    }
}
</script>

<style lang="scss" scoped>
@import 'index';
</style>
